Stack overflow executing regular expression